package com.comdosoft.comdoandroidbase.adapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.comdosoft.comdoandroidbase.R;

import java.util.List;

import cn.xiaolang.mobi1.logic.dto.Customer;

public class MyAdapter extends BaseAdapter {
	private LayoutInflater inflater;
	private ViewHolder holder = null;
	private Context context;
	private List<Customer> custs;
	private int index=0;
	public int getIndex() {
		return index;
	}
	public void setIndex(int index) {
		this.index = index;
	}
	public MyAdapter(Context c,List<Customer> custs) {
		this.context=c;
		this.custs=custs;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return custs.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return custs.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		inflater = LayoutInflater.from(context);
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.mylistitem, null);
			holder.tv_title=(TextView)convertView.findViewById(R.id.text);
			holder.dz=(ImageView)convertView.findViewById(R.id.dz);
			holder.right=(ImageView)convertView.findViewById(R.id.right);
			
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.right.setVisibility(View.INVISIBLE);
		holder.dz.setVisibility(View.INVISIBLE);
		if(index==position){
			holder.right.setVisibility(View.VISIBLE);
			holder.dz.setVisibility(View.VISIBLE);
		}
		holder.tv_title.setText(custs.get(position).getLxdz());
		return convertView;
	}
	public final class ViewHolder {
		public TextView tv_title, tv_time;
		public ImageView dz,right;

	}
}
